package com.twu.biblioteca.service;

import com.twu.biblioteca.model.user;

import java.io.InputStream;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * User: st
 * Date: 14-4-23
 * Time: 下午4:22
 * To change this template use File | Settings | File Templates.
 */
public class login {
    public String getInput(InputStream in)
    {
        Scanner sc = new Scanner(in);
        String option = sc.nextLine();
        return option;
    }
    public int checkLogin(user[]userList,InputStream in){
        System.out.println("Please in put userName.");
        String name=getInput(in);
        System.out.println("Please in put password.");
        String password = getInput(in);
        int len=0;
        while (len<userList.length&&userList[len]!=null) {
            if(userList[len].getCustomerName().equals(name)&&userList[len].getPassWord().equals(password)) {
               return len;
            }
            len++;
        }
        return userList.length+1;
    }
}
